l = [1, 1, 3, 1, 5]
t = 1

def fun(l, t):
    a = 0
    for _ in range(len(l)):
        if t in l:
            l.remove(t)
            a += 1
    for _ in range(a):
        l.insert(0, t)
    return l


print(fun(l, t))


